<template>
    <el-card shadow="hover">
    <template #header>
      <div class="card-header">
        <el-button class="button" color="#1baeae">+ 解除禁用</el-button>
        <el-button class="button" color="#f56c6c" :icon="Delete">禁用账户</el-button>
      </div>
    </template>
    <el-table v-loading="state.loading" ref="multipleTableRef" :data="state.tableData" style="width: 100%" @selection-change="handleSelectionChange">
      <el-table-column type="selection" />
      <el-table-column property="loginName" label="昵称" />
      <el-table-column property="nickName" label="登录名" />
      <el-table-column label="身份状态">
        <template #default="{row}">
          <span :style="{color:row.isDeleted === 0 ? 'green' : 'red'}">{{row.isDeleted === 0 ? '正常' : '禁用'}}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否注销">
        <template #default="{row}">
          <span :style="{color:row.lockedFlag === 0 ? 'green' : 'red'}">{{row.lockedFlag === 0 ? '正常' : '禁用'}}</span>
        </template>
      </el-table-column>
      <el-table-column label="排序时间">
        <template #default="scope">{{ scope.row.createTime }}</template>
      </el-table-column>
    </el-table>
  </el-card>
  <el-pagination background layout="prev, pager, next" :total="state.total" :page-size="state.pageSize"
      @prev-click="prevClick" @next-click="nextClick" @current-change="currentChange" />
</template>

<script>
  export default {
    name: 'memberAdministration',
  }
</script>
<script setup>
  import {
    Delete
  } from '@element-plus/icons-vue'
  import { onBeforeMount,reactive } from "vue" 
    import api from '@/http'
    import {
    ElMessage
  } from 'element-plus'
  const state = reactive({
    tableData: [],
    total: 0,
    pageSize: 10,
    currentPage: 1,
    loading: false,
  })
  onBeforeMount(() => {
    init();
  })
  // 渲染列表
  const init = async () => {
    state.loading = true;
    const {
      data,
      resultCode
    } = await api.member.userList(state.currentPage, state.pageSize);
    if (resultCode === 200) {
      console.log(data.list);
      state.tableData = data.list;
      state.total = data.totalCount;
      state.currentPage = data.currPage;
      state.pageSize = data.pageSize;
      state.loading = false;
    } else {
      ElMessage({
        showClose: true,
        message: '数据渲染失败，请稍后再试！！',
        type: 'error',
      })
      state.loading = false;
    }
  }
</script>

<style lang="less" scoped>
  .button {
    color: #fff;
  }
</style>